package com.xbts.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xbts.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xbts.common.log.annotation.Log;
import com.xbts.common.core.web.controller.BaseController;
import com.xbts.common.core.web.domain.AjaxResult;
import com.xbts.common.log.enums.BusinessType;
import com.xbts.system.domain.SysMonitorSort;
import com.xbts.system.service.ISysMonitorSortService;
import com.xbts.common.core.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import com.xbts.common.core.web.page.TableDataInfo;

/**
 * 监控排序Controller
 * 
 * @author xbts
 * @date 2023-12-22
 */
@Api(tags = "监控排序管理")
@RestController
@RequestMapping("/monitor/sort")
public class SysMonitorSortController extends BaseController {

    @Autowired
    private ISysMonitorSortService sysMonitorSortService;

    /**
     * 新增监控排序
     */
    @ApiOperation("新增监控排序")
    @RequiresPermissions("system:monitor:add")
    @Log(title = "监控排序", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysMonitorSort sysMonitorSort) {
        return toAjax(sysMonitorSortService.saveSysMonitorSort(sysMonitorSort));
    }

    /**
     * 修改监控排序
     */
    @ApiOperation("更新监控排序")
    @RequiresPermissions("system:monitor:edit")
    @Log(title = "监控排序", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysMonitorSort sysMonitorSort) {
        return toAjax(sysMonitorSortService.updateSysMonitorSortByMonitorIdAndType(sysMonitorSort));
    }
    /**
     * 关闭监控排序
     */
    @ApiOperation("关闭监控排序")
    @RequiresPermissions("system:monitor:edit")
    @Log(title = "监控排序", businessType = BusinessType.UPDATE)
    @PutMapping("/cancel")
    public AjaxResult cancel(@RequestBody SysMonitorSort sysMonitorSort) {
        return toAjax(sysMonitorSortService.remove(new LambdaQueryWrapper<SysMonitorSort>()
                .eq(SysMonitorSort::getMonitorId, sysMonitorSort.getMonitorId())
                .eq(SysMonitorSort::getType, sysMonitorSort.getType())));
    }

}
